import { createApp } from 'vue'
import App from './App.vue'
import router from "@/router";
import 'element-plus/dist/index.css'
import ElementPlus from 'element-plus'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'
import axios from "axios";
import {dayjs} from "element-plus";
axios.defaults.baseURL = 'http://localhost:9099';
axios.interceptors.request.use(config => {
    const token = localStorage.getItem('sessionToken');
    if (token) {
        config.headers.Authorization = token;
    }
    return config;
}, error => {
    return Promise.reject(error);
});

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
    app.component(key, component)
}
app.config.globalProperties.$dayjs = dayjs
app.use(router).use(ElementPlus).mount('#app')
